
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<!-- <link rel="shortcut icon" href="img/logo.ico" /> -->
		<title>会员业务奖励</title>
    <link href="plugin/date/date.css" rel="stylesheet">
		<link href="bootstrap/css/bootstrap3.min.css" rel="stylesheet">
    <link href="//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
		<link rel="stylesheet" href="css/nav.css" />
  </head>
  <body>
	  <!--导航-->
      <nav class="navbar navbar-inverse">
        <div class="container-fluid">
          <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-2">
              <span class="sr-only">Toggle navigation</span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
            </button>
  	          	<a class="navbar-brand" href=""><img src="images/admin_logo.png" alt=""></a>
          </div>

          <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-2">
            <ul class="nav navbar-nav" id="nav">

            </ul>
            <ul class="nav navbar-nav navbar-right">
              <li class="dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">欢迎您：<span id="uname"></span><span class="caret"></span></a>
                <ul class="dropdown-menu" role="menu">
                  <li><a href="change_pass.html">修改密码</a></li>
                  <li><a id="loginOut" href="#">退出登陆</a></li>
                </ul>
              </li>
            </ul>
          </div>
        </div>
      </nav>
    <div class="container-fluid">
			<div class="row bcert-box">
        <ol class="breadcrumb">
          <li><a href="javascript:;">主页</a></li>
          <li>会员管理</li>
          <li class="active">会员业务奖励</li>
        </ol>

        <form class="form-inline searchForm">
          <div class="form-group">
            <span class="theme-title">会员类型:</span>
            <select class="form-control drop-down" name='operationType' id="memberType">
              <option value="">全部</option>
              <option value="1">普通会员</option>
              <option value="2">银牌会员</option>
			  <option value="3">金牌会员</option>
			  <option value="4">合作方</option>
            </select>
          </div>
		  <div class="form-group">
            <span class="theme-title">会员状态:</span>
            <select class="form-control drop-down" name='operationType' id="publishType">
              <option value="">奖励类型</option>
              <option value="1">自主做单</option>
              <option value="2">推荐业务</option>
            </select>
          </div>
          <div class="form-group">
              <input type="text" class="form-control" style="padding-left:12px;" name="memberName" id="memberName" placeholder="姓名">
          </div>
          <div class="form-group">
              <input type="text" class="form-control" style="padding-left:12px;" name="memberMobile" id="memberMobile" placeholder="手机号">
          </div>
          <div class="form-group">
              <input type="text" class="form-control" style="padding-left:12px;" name="startTime" title="错误"
               readonly="readonly"
               data-container="body"
               data-toggle="popover"
               data-placement="bottom"
               data-content="开始时间不能大于结束时间!"
               id="startTime" placeholder="开始时间">
          </div>
          <div class="form-group">
              <input type="text" class="form-control" style="padding-left:12px;" readonly="readonly" name="endTime" id="endTime" placeholder="结束时间">
          </div>
          <div class="form-group">
            <button type="button" class="btn btn-primary btn-success" id="Reset"></span>重置</button>
            <button type="button" class="btn btn-primary btn-default" id="QueryBtn" data-toggle="button" aria-pressed="false" autocomplete="off">查询</button>
            <!-- <button type="button" class="btn btn-primary btn-success" id="dlexcle"></span>&nbsp;导出excle</button> -->
          </div>
        </form>
        <div class="table">
          <table class="table table-bordered table-striped" id="integralList">

          </table>
        </div>
      </div>
      <!-- 分页 -->
        <nav aria-label="...">
          <div class="">
            <span id="pageNum">共&nbsp;<strong></strong>&nbsp;页&nbsp;/&nbsp;</span><span id="totalNum">&nbsp;<strong>0</strong>&nbsp;条数据</span>
          </div>
          <ul id="example"></ul>
        </nav>
    </div>
  </body>
  <script src="js/jquery.min.js"></script>
  <script type="text/javascript" src="plugin/layer/layer.js"></script>
  <script type="text/javascript" src="js/cookie.js"></script>
  <script type="text/javascript" src="js/common.js"></script>
  <script type="text/javascript" src="bootstrap/js/bootstrap.min.js" ></script>
  <script type="text/javascript" src="js/bootstrap-paginator.js"></script>
  <script type="text/javascript" src="plugin/date/date.js"></script>
  <script type="text/javascript" src="plugin/date/date.zh-CN.js"></script>
  <script>

  $("document").ready(function(){
    integralListPaga()
  })

  //分页
  function integralListPaga (){
    $.ajax({
        //分页
        url: serverURL + '/credit/queryMemberCredit',
        type: "post",
        data: {
          'memberName':$('#memberName').val(),
          'memberMobile':$('#memberMobile').val(),
		  'memberType':$('#memberType').val(),
          'publishType':$('#publishType').val(),
          'startTime':$('#startTime').val(),
          'endTime':$('#endTime').val(),
          'page': page,
          'pageSize': pagesize
        },
        dataType: "json",
        success: function (data) {
           if (data.code == 200) {
             integralList = data.data
             OpendList(integralList);
             $('#pageNum strong').html('0')
             $('#totalNum strong').html('0')
             $('#totalNum strong').html(data.data.count)
             console.log(data);
             if (data.data.count >= 1) {
              var pageCount = Math.ceil(data.data.count/pagesize); //取到pageCount的值
              $('#pageNum strong').html(pageCount)
              var currentPage = page; //得到urrentPage
            }else if(data.data.count == 0){
              $('#pageNum strong').html('0')
              $("#example").empty();
              return false;
            }
            var options = {
                bootstrapMajorVersion: 3, //版本
                currentPage: currentPage, //当前页数
                totalPages: pageCount, //总页数
                itemTexts: function (type, page, current) {
                    switch (type) {
                        case "first":
                            return "首页";
                        case "prev":
                            return "上一页";
                        case "next":
                            return "下一页";
                        case "last":
                            return "末页";
                        case "page":
                            return page;
                    }
                },//点击事件，用于通过Ajax来刷新整个List列表
                onPageClicked: function (event, originalEvent, type, page) {
                    $.ajax({
                        url: serverURL +  '/credit/queryMemberCredit',
                        type: "post",
                        dataType: "json",
                        data: {
						  'memberName':$('#memberName').val(),
  				          'memberMobile':$('#memberMobile').val(),
  						  'memberType':$('#memberType').val(),
  				          'publishType':$('#publishType').val(),
                          'startTime':$('#startTime').val(),
                          'endTime':$('#endTime').val(),
                          "page": +page,
                          "pageSize":pagesize
                        },
                        success: function (data1) {
                            console.log(data.msg)
                            if (data1.code == 400) {
                              alert("登陆超时请重新登陆")
                              window.location.href = "login.html";
                            }
                            var integralList = data1.data;
                            OpendList(integralList);
                        }
                    });
                }

            };
            $('#example').bootstrapPaginator(options);
            // inputEmpty(); //条件初始化
           }else if (data.code == 400) {
             alert("登陆超时请重新登陆")
             window.location.href = "login.html";
           }
        }
    });
  }

  //数据渲染
  function OpendList(integralList){
    var result = '';
    $('#integralList').empty();
    $('#integralList').append(
      '<tr>' +
      '<th>序号</th>' +
	  '<th>姓名</th>' +
      '<th>手机号</th>' +
      '<th>会员类型</th>' +
      '<th>奖励类型</th>' +
	  '<th>业务奖励</th>' +
	  '<th>债权编号</th>' +
	  '<th>债权人手机号</th>' +
	  '<th>债权金额</th>' +
	  '<th>法律咨询费比列</th>' +
	  '<th>奖励比例</th>' +
	  '<th>奖励时间</th>' +
      '</tr>'
    );
    for (var i = 0; i < integralList.list.length; i++) {
		var memberType = ''
		if (integralList.list[i].memberType == 1) {
			memberType = '普通会员'
		}else if (integralList.list[i].memberType == 2) {
			memberType = '银牌会员'
		}else if (integralList.list[i].memberType == 3) {
			memberType = '金牌会员'
		}else if (integralList.list[i].memberType == 4) {
			memberType = '合作方'
		}
		var partnerId = ''
		if (integralList.list[i].partnerId == 1) {
			partnerId = '省级代理'
		}else if (integralList.list[i].partnerId == 2) {
			partnerId = '市级代理'
		}else if (integralList.list[i].partnerId == 3) {
			partnerId = '县级代理'
		}else {
			partnerId = ''
		}
        var time = getMyDate(integralList.list[i].createTime);
        result +=
               '<tr>'+
                 '<td>'+ integralList.list[i].memberId +'</td>'+
                 '<td>'+ integralList.list[i].memberName +'</td>'+
                 '<td>'+ integralList.list[i].memberMobile +'</td>'+
                 '<td>'+ integralList.list[i].memberTypeName +'</td>'+
                 '<td>'+ integralList.list[i].publishType +'</td>'+
                 '<td>'+ integralList.list[i].income +'</td>'+
				 '<td>'+ integralList.list[i].id +'</td>'+
				 '<td>'+ integralList.list[i].contact +'</td>'+
				 '<td>'+ integralList.list[i].amount +'</td>'+
				 '<td>'+ integralList.list[i].consultationFee +'</td>'+
				 '<td>'+ integralList.list[i].awardPer +'</td>'+
				 '<td>'+ integralList.list[i].ttime +'</td>'+
				 '</tr>'
    }
    $('#integralList').append(result)

  }
  //查询
  $('#QueryBtn').click(function(){
    integralListPaga()
  })

  function compareDate(startTime, endTime) {
         return new Date(startTime).getTime() > new Date(endTime).getTime();
     }

     function checkStartAndEndTime() {
         if(compareDate($('#startTime').val(), $('#endTime').val())){
             $('#startTime').addClass("card-warning");
             $('#startTime').popover('show');

         }else{
             $('#startTime').removeClass("card-warning");
             $('#startTime').popover('hide')
         }
     }

     //时间选择
     $("#startTime").datetimepicker({
         format: "yyyy-mm-dd",
         autoclose: true,
         todayBtn: true,
         todayHighlight: true,
        //  endTime:new Date(),
         showMeridian: true,
         pickerPosition: "bottom-left",
         language: 'zh-CN',//中文，需要引用zh-CN.js包
         startView: 2,//月视图
         minView: 2,//日期时间选择器所能够提供的最精确的时间选择视图
     }).change(function () {
         checkStartAndEndTime();
     });
     $("#endTime").datetimepicker({
         format: "yyyy-mm-dd",
         autoclose: true,
         todayBtn: true,
         todayHighlight: true,
        //  endTime:new Date(),
         showMeridian: true,
         pickerPosition: "bottom-left",
         language: 'zh-CN',//中文，需要引用zh-CN.js包
         startView: 2,//月视图
         minView: 2,//日期时间选择器所能够提供的最精确的时间选择视图
     }).change(function () {
         checkStartAndEndTime();
     });
  </script>
</html>
